package pri.damai.xiaowu.common.log.trace.feign;

import feign.RequestInterceptor;
import feign.RequestTemplate;
import lombok.extern.slf4j.Slf4j;
import pri.damai.xiaowu.common.log.trace.ThreadMdcUtil;

import static pri.damai.xiaowu.common.core.constant.TraceConstant.TRACE_ID;

/**
 * feign 请求拦截器
 *
 * @description
 * @author YangXinFu
 * @date 9:17 2022/7/13
 **/
@Slf4j
public class FeignTraceInterceptor implements RequestInterceptor {

    public FeignTraceInterceptor() {
        log.info("【Xiao Wu】 FeignTraceInterceptor 配置成功。");
    }

    @Override
    public void apply(RequestTemplate requestTemplate) {
        log.info("路过");
        requestTemplate.header(TRACE_ID, ThreadMdcUtil.getTraceId());
    }
}
